VERSION 5.00
Begin VB.Form frmDGDisclaimer 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Dangerous Goods Disclaimer"
   ClientHeight    =   4245
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5655
   ControlBox      =   0   'False
   Icon            =   "frmDGDisclaimer.frx":0000
   ScaleHeight     =   4245
   ScaleWidth      =   5655
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer timerAuto 
      Interval        =   1000
      Left            =   120
      Top             =   3720
   End
   Begin VB.CommandButton cmdOK 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&OK"
      Height          =   315
      Left            =   2220
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   3780
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Disclaimer"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   3495
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5415
      Begin VB.TextBox Text1 
         Appearance      =   0  'Flat
         BorderStyle     =   0  'None
         Height          =   3015
         Left            =   180
         MultiLine       =   -1  'True
         TabIndex        =   2
         Text            =   "frmDGDisclaimer.frx":030A
         Top             =   360
         Width           =   5055
      End
   End
End
Attribute VB_Name = "frmDGDisclaimer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
Option Compare Text



' 2008-07-01, JFW, Canadian client database.

'2/8/05 - API function declaration to add DSN to system used in AddDSN() function.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal _
   hwndParent As Long, ByVal fRequest As Long, ByVal _
   lpszDriver As String, ByVal lpszAttributes As String) As Long

Private Sub cmdOK_Click()
    frmShip.Show
    Me.Hide
End Sub

Private Sub Form_Initialize()

    NASCAR_VERSION = "FSMSClient v800.2"

End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 4/3/2006
' Purpose   : Check to ensure DSN is setup before proceeding, if not show error and exit.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()

    Call modCanada.ShipInitialize
    
    Call Initialize(Me)
    
    Set g_connFSMSClient = New ADODB.Connection
    
    If Not FSMSClientMDBConnect Then
            MsgBox "Unable to connect to the FSMS Client Database." & vbCrLf & _
                   "Verify you have the proper DSN, name " & "FSMSClient800CA4" & " setup for " & NASCAR_VERSION & "." & vbCrLf & _
                   "Check the path to the FSMSClient.mdb file." & vbCrLf & _
                   "Or check alternative settings in FSMSClient.xml." & vbCrLf & _
                   "Shutting Down.", vbCritical + vbApplicationModal, "Database Connection Error"
            Unload Me
            Unload frmShip
            Set g_connFSMSClient = Nothing
            End
    End If
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : FSMSClientMDBConnect
' DateTime  : 12/8/2004
' Purpose   : Connects to FSMSClient.mdb and returns True if successful.
' Call from : Form_Load
'---------------------------------------------------------------------------------------
'
Public Function FSMSClientMDBConnect() As Boolean
    On Error GoTo EH
    
    Dim intStep As Integer
    intStep = 1
    
    If GetSystemName = "WINXPC9CA96EA3" Then
        intStep = 2
    End If
    
Connect:
    Select Case intStep
        
    Case 1:
        On Error GoTo EH
        g_connFSMSClient.Open "DSN=FSMSClient800CA4" ' & NASCAR_VERSION
        
    Case 2:
        On Error GoTo EH
        If g_clsSettings.Setting("ClientDBConnection") <> "" Then
            g_connFSMSClient.Open g_clsSettings.Setting("ClientDBConnection")
        ElseIf GetSystemName = "WINXPC9CA96EA3" And NASCAR_VERSION >= "FSMSClient v800.2.1" Then
            g_connFSMSClient.Open "Driver={SQL Server};Server=CAN-00406583;Database=FSMSClientV800CA;Uid=sa;Pwd=john2014;"
        Else
            Err.Raise 12345, "DGDisclaimer", "Configuration required for ClientDBConnection."
        End If

    Case 3:
        On Error GoTo EH
        ' g_connFSMSClient.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Projects\FSMSClient\Database\FSMSClient.mdb;Uid=Admin;Pwd=;"
        If g_clsSettings.Setting("ClientDBConnection") <> "" Then
            g_connFSMSClient.Open g_clsSettings.Setting("ClientDBConnection")
        ElseIf GetSystemName = "WINXPC9CA96EA3" Then
            g_connFSMSClient.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\Projects\FSMSClient\Database\FSMSClient.mdb;Uid=Admin;Pwd=;"
        Else
            g_clsSettings.Setting("ClientDBConnection") = ""
            g_clsSettings.SaveSettings
            g_connFSMSClient.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "\FSMSClient.mdb;Uid=Admin;Pwd=;"
        End If

    Case Else
        Exit Function
        
    End Select
    
    FSMSClientMDBConnect = True
    
    Exit Function
EH:
    g_strErrorLocation = "FSMSClient.frmDGDisclaimer.FSMSClientMDBConnect, " & Err.Source & ", " & Err.Description
    DebugPrint g_strErrorLocation
    intStep = intStep + 1
    Resume Connect
    
End Function

Private Sub timerAuto_Timer()
    On Error GoTo EH

    timerAuto.Enabled = False
    
    If AfterDGDisclaimer Then
        frmShip.Show
        Me.Hide
    End If

    Exit Sub
EH:
    MsgBox "Unable to start in DGDisclaimer, " & Err.Source & ", " & Err.Description

End Sub
